package com.ltx.vizflowservice.config;

import com.ltx.vizflowservice.handler.TokenInterceptor;
import com.ltx.vizflowservice.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置
 */
@Configuration
@RequiredArgsConstructor
public class WebMvcConfig implements WebMvcConfigurer {

    private final UserService userService;

    private final StringRedisTemplate redisTemplate;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new TokenInterceptor(userService,redisTemplate))
                .addPathPatterns("/**")
                .excludePathPatterns("/login","/register","/resetPassword","/sms/send");
    }
}